package model.evaluate.controller;

import model.evaluate.entity.Evaluate;
import model.evaluate.service.IEvaluateService;
import model.newhouse.entity.Result;
import model.newhouse.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class evaluateController {

    @Autowired
   private IEvaluateService evaluateService ;
    @GetMapping("/evaluate")
    public Result findEvaluate(){
        List<Evaluate> evaluateList = evaluateService.findAll();
        System.out.println(evaluateList);
        Result result = new Result(true, StatusCode.OK,"查询成功",evaluateList);
        return  result;
    }

    @PostMapping("/save")
    public Result add(Evaluate evaluate){
        System.out.println(evaluate.getEvaluateDetail());
         evaluateService.save(evaluate);
        Result result = new Result(true, StatusCode.OK,"保存成功",evaluate);
        return  result;
    }

    @DeleteMapping("/del/{evaluateUsername}")
    public Result delete(@PathVariable("evaluateUsername") String evaluateUsername){
        evaluateService.del(evaluateUsername);
        Result result = new Result(true, StatusCode.OK,"删除成功");
        return  result;
    }
}
